<?php

// 删除合作机构
// DELETE agency.admin.delete

namespace app\api\resource\agency\admin;
use think\Db;

class Delete
{
    // 方法
    public $_method = ['DELETE'];
    // 前置
    public $_pre    = ['adminLogin'];
    // 描述
    public $_description = '删除合作机构';
    // 参数
    public $_param  = [
        'id' => '合作机构主键',
    ];
    // 返回
    public $_return = [
        204 => '删除成功',
        500 => '服务器异常',
    ];

    public function run(&$request)
    {
        $id  = $request->delete('id/d',0);

        if (0 == $id) return [422,'合作机构主键必须'];

        $num = Db::name('agency')->where('id',$id)->delete();

        return ($num >0) ? [204,''] : 500;
    }
}